/*------------------------------------------------
<> cBITMAP class
<> 2008.07.31 - Robert Vanca
<> v0.8

Class for handling bitmaps.
Features:
	- Loading a bitmap
	- Drawing bitmaps, with alpha
	- supported bitmaps: 16,24,32 bit.

TODO:	- RLE, and other compression support.
		- OPTIMIZE alpha bitmap drawing.

--------------------------------------------------*/
#pragma once
#ifndef _BASELIB_BITMAP_H
#define _BASELIB_BITMAP_H

class BASE_RENDERER;
class FRAME_BUFFER;

#pragma pack(push,bitmap_struct,1)

struct BITMAP_HEADER
{
	unsigned long	Size; 
	long			Width; 
	long			Height; 
	unsigned short	Planes; 
	unsigned short	BitCount; 
	unsigned long	Compression; 
	unsigned long	SizeImage; 
	long			XPelsPerMeter; 
	long			YPelsPerMeter; 
	unsigned long	ClrUsed; 
	unsigned long	ClrImportant; 
};

struct BITMAP_FILEHEADER
{
	unsigned short	fType;  
	unsigned long	fSize;  
	unsigned short	fReserved1;  
	unsigned short	fReserved2;  
	unsigned long	OffBits;  
};

#pragma pack(pop,bitmap_struct)

class cBITMAP
{

public:
	BITMAP_FILEHEADER*	pFileHeader;
	BITMAP_HEADER*		pHeader;
	void*				thepixels;
	float*				alphachannel;

public:
	cBITMAP();
	~cBITMAP();

	inline int GetSize() {return pHeader->Width*pHeader->Height;}

	void Load(const wchar_t* filename);
	void Render(int,int,BASE_RENDERER* pRenderer);
	void BlitBitmap(int,int,FRAME_BUFFER*);
	void BlitBitmapAlpha(int,int,FRAME_BUFFER*);


};


#endif //_BASELIB_BITMAP_H
